﻿#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common qw(POST);
$URL  = "http://www.example.com/login.php";
$UA   = LWP::UserAgent->new();

$req  = HTTP::Request::Common::POST( "$URL",
   Content_Type => 'form-data',
   Content => [
    USERNAME => 'admin',
    PASSWORD => '12345',
    Submit   => 'Zaloguj'
   ]
);
$resp = $UA->request($req);

# Kontrola błędów. Wyświetlenie strony, jeśli wszystko jest OK.
if ( ( $resp->code() >= 200 ) && ( $resp->code() < 400 ) ) {
    print $resp->decoded_content;
} else {
    print "Błąd: " . $resp->status_line . "\n";
}
